//
//  StatusTextView.m
//  微博2期
//
//  Created by J on 16/1/2.
//
//

#import "StatusTextView.h"

@implementation StatusTextView
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.scrollEnabled = NO;
        self.editable = NO;
        self.selectable = NO;
        self.textContainerInset = UIEdgeInsetsMake(0, -5, 0, -5);
        self.backgroundColor = [UIColor clearColor];
        
    }
    return self;
}



- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    //触摸对象
    UITouch* touch = [touches anyObject];
    
    //触摸点
    CGPoint point = [touch locationInView:self];
    
    self.selectedRange = NSMakeRange(10,9);
  NSArray* array =  [self selectionRectsForRange:self.selectedTextRange];//返回数组 因为可能会换行
    for (UITextSelectionRect* rect in array) {
        NSLog(@"%@",NSStringFromCGRect(rect.rect));
        UIView* temp = [UIView new];
        temp.backgroundColor = [UIColor orangeColor];
        temp.frame = rect.rect;
        [self addSubview:temp];
        
    }
    
    //找出触摸点在哪个特殊字符上面
    //在被触摸的字符串后面显示一段高亮的背景
    
    
    
}

- (void)setMultipleTouchEnabled:(BOOL)multipleTouchEnabled{
    //去掉特殊字符串后面的高亮背景
}
@end
